package com.lcf.framework.utils;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

/**
 * 线程池
 * @author lcf
 */
@Component
public class ThreadUtils {
    @Resource
    @Qualifier("globalTaskExecutor")  // 注入自定义线程池Bean
    private ThreadPoolTaskExecutor executor;

    public void execute(Runnable runnable) {
        executor.execute(runnable);
    }

    public ThreadPoolTaskExecutor getThreadPool() {
        return executor;
    }
}
